﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UFSoft.UBF.Business;
using UFSoft.UBF.Util.DataAccess;

namespace MF_HSD_BEPlug
{
    public partial class VoucherDeleted : UFSoft.UBF.Eventing.IEventSubscriber
    {
        void UFSoft.UBF.Eventing.IEventSubscriber.Notify(object[] args)
        {
            this.Do_Notify(args);
        }

        private void Do_Notify(object[] args)
        {
            #region 从事件参数中取得当前业务实体													 

            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
                return;
            BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            if (key == null)
                return;
            UFIDA.U9.GL.Voucher.Voucher holder = key.GetEntity() as UFIDA.U9.GL.Voucher.Voucher;
            if (holder == null)
                return;
            //内部结算凭证删除 需要清空来源凭证的接收方凭证字段--切换到海四达是要换私有段
            UFIDA.U9.GL.Voucher.Voucher srcV = UFIDA.U9.GL.Voucher.Voucher.Finder.Find("DescFlexField.PrivateDescSeg2='" + holder.VoucherDisplayCode + "'");
            if (srcV != null)
            {
                string sql = "Update GL_Voucher set DescFlexField_PrivateDescSeg2='' where ID = " + srcV.ID + "";
                DataAccessor.RunSQL(DataAccessor.GetConn(), sql.ToString(), null);
            }
           
            #endregion

        }
    }
}
